<template>
  <div>
    <el-dialog :append-to-body="true" :close-on-click-modal="false" :before-close="cancel" :visible.sync="dialog"
    title="查看" width="800px">
    <el-form ref="form" :model="form" :rules="rules" size="small" label-width="140px">

      <el-form-item label="奖品类型">
        {{ form.prizeType == 1 ? '实物' : form.prizeType == 2 ? '优惠券' : '微信返现' }}
      </el-form-item>

      <el-form-item label="奖品图片" v-if="form.prizeType == 1">
        <img :src="form.prizeImage" alt="" style="width: 150px;height: 150px;">
      </el-form-item>

      <!-- <div v-if="form.prizeType==2">
        <el-form-item label="优惠券选择">
          <el-select v-model="form.couponId" filterable placeholder="请选择优惠券">
            <el-option
              v-for="item in CouponList"
              :key="item.id"
              :label="item.title"
              :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>
      </div>
      <div v-if="form.prizeType==3">
         <el-form-item label="返现金额">
        <el-input-number v-model="form.prizePrice" :min="0" label="请输入返现金额"></el-input-number>
      </el-form-item>
      </div> -->

      <el-form-item label="奖品名称">
        {{ form.prizeName }}
      </el-form-item>
      <el-form-item label="使用类型" v-if="form.prizeType == 2">
        {{ !form.yxStoreCoupon.type ? '平台券' : '商家券' }}
      </el-form-item>
      <el-form-item label="奖品价值">
        {{ form.prizePrice }}元
      </el-form-item>
      <el-form-item label="奖品描述">
        {{ form.prizeDescription }}
      </el-form-item>
      <el-form-item label="有效时间">
        {{ form.validity }}
      </el-form-item>
      <el-form-item label="收获地址" v-if="form.prizeType == 1">
        <div v-if="form.yxUserAddress">
          {{ form.yxUserAddress.province }}{{ form.yxUserAddress.city }}{{ form.yxUserAddress.district }}
        </div>
        <div v-else>
          暂无
        </div>
      </el-form-item>
      <el-form-item label="地址详情" v-if="form.prizeType == 1">
        <div v-if="form.yxUserAddress">
          {{ form.yxUserAddress.detail }} {{ form.yxUserAddress.houseNumber }}
        </div>
        <div v-else>
          暂无
        </div>
      </el-form-item>
      <el-form-item label="物流状态" v-if="form.prizeType == 1">
        <el-button type="primary" @click="kuaidiDialogVisible = true">查看物流信息</el-button>
      </el-form-item>

      <!-- <el-form-item label="兑换方式">
            <el-radio-group v-model="form.wayReceiving">
            <el-radio :label=1>邮寄</el-radio>
            <el-radio :label=2>线下领取</el-radio>
            <el-radio :label=3>电子兑换</el-radio>
          </el-radio-group>
          </el-form-item> -->
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="text" @click="cancel">取消</el-button>
      <el-button :loading="loading" type="primary" @click="cancel">确认</el-button>
    </div>
  </el-dialog>

  <el-dialog title="订单跟踪"
               :visible.sync="kuaidiDialogVisible"
               width="40%">
      <el-steps direction="vertical"
                :active="90"
                finish-status="success"
                space="50px">
        <el-step  v-for="item in form.expressInfo.data"
                  :key="item.acceptStation"
                  :title="item.acceptStation"
                  :description="item.acceptTime"></el-step>
      </el-steps>
    </el-dialog>
  </div>
</template>

<script>
import { add, edit, Coupon } from '@/api/yxSystemPrize'
import cgood from '@/views/components/goods'
import singlePic from '@/components/singlematerial'

export default {
  components: { cgood, singlePic },

  data() {
    return {
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 8.64e7;
        },

      },
      defaultStartDate: new Date(2023, 1, 1),
      loading: false, dialog: false,
      form: {
        expressInfo: {
          data: []
        }
      },
      CouponList: [],
      rules: {
      },
      kuaidiDialogVisible: false
    }
  },
  methods: {
    handleDateTimeChange(value) {
      console.log(value)
    },
    getCouponList() {
      Coupon({
        page: 0,
        size: 20
      }).then(res => {
        this.CouponList = res.content
      })
    },
    getGoods(p) {
      var ids = []
      p.forEach((item, index) => {
        ids.push(item.id)
      })
      this.form.productId = ids.join(",")
    },
    cancel() {
      this.resetForm()
    },

    resetForm() {
      this.dialog = false
      this.form = {
        expressInfo: {
          data: []
        }
      }
    }
  }
}
</script>

<style scoped></style>